import { CashbackTypes } from "@/api/cashback"; import { UserVipInfo } from "@/api/user"; import Box from "@/components/Box"; import { vipImages } from "@/utils/constant"; import { flatPoint, percentage } from "@/utils/methods"; import { server } from "@/utils/server"; import { getTranslations } from "next-intl/server"; import Image from "next/image"; import CashbackTable from "./CashbackTable"; import Progress from "./components/Progress"; import Week from "./Week"; const getVipInfoApi = async () => { return server .request({ url: "/v1/api/user/user_vip_info", method: "post", }) .then((res) => { if (res.code === 200) return res.data; return { vip_exp: 0, vip_level: 0, vip_next_level: 0, vip_score_exp: 0, }; }); }; const getCashBackApi = async (): Promise => { return server .request({ url: "/v1/api/front/activity_cash", method: "post", }) .then((res) => { return res.data; }) .catch((error) => { return { rules: [], last_period: { end_time: 0, start_time: 0 }, next_period: { end_time: 0, start_time: 0, }, amount: 0, bet: 0, status: "expired", max_amount: 0, } as CashbackTypes; }); }; const CashbackInfo = async () => { const vipInfo = await getVipInfoApi(); const cashbackInfo = await getCashBackApi(); const currentGrade = cashbackInfo.rules?.find( (item) => item.level === (vipInfo.vip_level || 1) ); const maxGrade = cashbackInfo.rules?.at(-1); const t = await getTranslations(); const vipIconElement = vipImages.map((item, index) => { if (item.leve === vipInfo.vip_level) { return (
{"vip"} {item.leve}
); } }); return ( <>
{vipIconElement}
{currentGrade?.cashback}% {t("cashback.cashbackTitle")} Max {maxGrade?.cashback}%
{t("ProfilePage.expTips", { exp: flatPoint(vipInfo.vip_score_exp - vipInfo.vip_exp), })} VIP{vipInfo.vip_next_level}

{t("cashback.rules")}

  • {t("cashback.rulesFirst")}
  • {t("cashback.rulesSecond")}
  • {t("cashback.rulesThird")}
  • {t("cashback.rulesFourth")}
  • {t("cashback.rulesFifth")}
  • {t("cashback.rulesSixth", { max: cashbackInfo.max_amount ?? 0 })}
  • {t("cashback.rulesSeventh")}
); }; export default CashbackInfo;